package com.huazhi.wzsnw.Filter;

import org.apache.shiro.subject.Subject;
import org.apache.shiro.web.filter.authz.AuthorizationFilter;

import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse;

// 用于自定义过滤器，过滤用户请求时是否是登录状态

public class LoginFilter extends AuthorizationFilter {

    @Override
    protected boolean isAccessAllowed(ServletRequest request, ServletResponse response, Object o) {
        Subject subject = getSubject(request, response);
        System.out.println(subject.getPrincipals()+".................");
        if (null != subject.getPrincipals()) {
            return true;
        }
        return false;
    }

    @Override
    protected boolean onAccessDenied(ServletRequest servletRequest, ServletResponse servletResponse) {
        return false;
    }


}
